package com.example.multilevelapprovalback.controller;
//审批记录管理
import com.example.multilevelapprovalback.pojo.ApprovalRecord;
import com.example.multilevelapprovalback.pojo.Result;
import com.example.multilevelapprovalback.service.ApprovalRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/approval-records")
public class ApprovalRecordController {
    @Autowired
    private ApprovalRecordService approvalRecordService;
    //新增审批记录
    @PostMapping
    public Result add(@RequestBody ApprovalRecord approvalRecord) {
        log.info("新增审批记录：{}",approvalRecord);
        approvalRecordService.add(approvalRecord);
        return Result.success();
    }
    //新增多条审批记录（批量审批）
    @PostMapping("/batch")
    public Result addBatch(@RequestBody ApprovalRecord approvalRecord) {
        log.info("新增多条审批记录：{}",approvalRecord);
        approvalRecordService.addBatch(approvalRecord);
        return Result.success();
    }
    @GetMapping
    //根据成果id查询审批记录
    public Result get(String achievementId) {
        List<ApprovalRecord> list = approvalRecordService.get(achievementId);
        return Result.success(list);
    }
}
